Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

envify

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

envify

Selectively replace Node-style environment variables with plain strings.

  • 3.4.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created

What is envify?

The envify npm package is a tool that allows you to replace environment variables in your JavaScript code with their corresponding values at build time. This is particularly useful for client-side applications where you want to inject environment-specific configurations without exposing sensitive information.

What are envify's main functionalities?

Basic Environment Variable Replacement

This feature allows you to replace environment variables in your JavaScript code with their actual values. In this example, the NODE_ENV variable is replaced with 'production' during the build process.

const envify = require('envify');
const browserify = require('browserify');

browserify('./main.js')
  .transform(envify({ NODE_ENV: 'production' }))
  .bundle()
  .pipe(process.stdout);

Using with Gulp

This feature demonstrates how to use envify with Gulp, a popular task runner. The environment variable NODE_ENV is replaced with 'production' during the build process, and the resulting bundle is saved to the './dist' directory.

const gulp = require('gulp');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const envify = require('envify/custom');

gulp.task('build', function () {
  return browserify('./main.js')
    .transform(envify({ NODE_ENV: 'production' }))
    .bundle()
    .pipe(source('bundle.js'))
    .pipe(gulp.dest('./dist'));
});

Using with Grunt

This feature shows how to use envify with Grunt, another popular task runner. The environment variable NODE_ENV is replaced with 'production' during the build process, and the resulting bundle is saved to the 'dist' directory.

module.exports = function(grunt) {
  grunt.initConfig({
    browserify: {
      dist: {
        files: {
          'dist/bundle.js': ['main.js']
        },
        options: {
          transform: [['envify', { NODE_ENV: 'production' }]]
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-browserify');
  grunt.registerTask('default', ['browserify']);
};

Other packages similar to envify

Keywords

FAQs

Package last updated on 21 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc